<template>
  <div class="wrap">
    <div class="ech-title">
      <p style="font-weight: 800;">汽油消费走势图</p>
      <!-- <span>计算于 : {{new Date()| fmtdate}}</span> -->
    </div>
    <div id="ech_6"></div>
  </div>
</template>
<script>
export default {
  props: {
    lineData: {
      type: null,
      default: null
    }
  },
  methods: {
    draw() {
      let arr = [];
      if(!this.lineData.qiList){
        return false
      }
      this.lineData.qiList.map(item => {
        arr.push(Number((item / 100)));
      });
      let myChart = this.$echarts.init(document.getElementById("ech_6"));
      var option = {
        tooltip: {
          trigger: "axis"
        },
        xAxis: {
          type: "category",
          boundaryGap: ["20%", "20%"],
          data: this.lineData.date,
          axisLine: {
            lineStyle: {
              color: "#999" 
            }
          },
          axisLabel: {
            formatter: "{value}日"
          }
        },
        yAxis: [
          {
            type: "value",
            splitArea: {
              show: true
            },

            nameTextStyle: {
              color: ["#0087ED"]
            },
            axisLine: {
              lineStyle: {
                color: "#999"
              }
            },
            axisLabel: {
              formatter: "{value}"
            }
          }
        ],
        series: [
          {
            data: arr,
            type: "line",
            smooth: true,
            areaStyle: {
              color: "#84B1F1"
            },
            itemStyle: {
              color: "#1488E2"
            }
          }
        ]
      };
      myChart.setOption(option);
    }
  },
  mounted() {
   
  },
  watch:{
    lineData(e){
       this.draw();
    }
  }
};
</script>
<style lang="scss" scoped>
#ech_1 {
  width: 100%;
  height: 400px;                           
}
#ech_6 {
  width: 100%;
  height: 400px;                           
}
.wrap {
  height: 480px;
  background: #fff;
}
.ech-title {
  overflow: hidden;
  padding-top: 15px;
  margin-left: 15px;
  p {
    color: #555;
    font-size: 18px;
  }
  span {
    font-size: 12px;
    color: #555;
    margin-top: 10px;
  }
}
</style>